// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// 导入全局样式表
import './assets/css/global.css'
import TreeTable from 'vue-table-with-tree-grid'

// 导入axios请求  接口
import axios from 'axios'


// 导入element-ui
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)
Vue.config.productionTip = false

// aixos配置请求的跟路径
axios.defaults.baseURL = 'https://lianghj.top:8888/api/private/v1/'

// 左侧菜单栏请求数据  token又叫令牌  请求拦截器  增加authorization字段，为了每次发起接口请求都要带上她
axios.interceptors.request.use(config => {
  console.log(config)
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.prototype.$http = axios 

Vue.component('tree-table',TreeTable)

// 时间的过滤器
Vue.filter('dateFormat',function(originVal){
  const dt = new Date(originVal)
  const y = dt.getFullYear()
  const m =(dt.getMonth() + 1+'').padStart(2,'0')
  const d = (dt.getDate()+'').padStart(2,'0')
  const hh= (dt.getHours()+'').padStart(2,'0')
  const mm = (dt.getMinutes()+'').padStart(2,'0')
  const SS= (dt.getSeconds()+'').padStart(2,'0')
  return `${y}-${m}-${d} ${hh}:${mm}:${SS}`
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
